package com.py.korona.ui.controls.fragments;

import android.annotation.SuppressLint;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;

@SuppressLint("UseSparseArrays")
public abstract class CustomFragment extends Fragment {
    private int optionsMenuResourceId;
    private int viewLayoutId;

    public abstract int optionsMenuResourceId();

    public abstract int viewLayoutId();

    public abstract void viewDidLoad();

    public CustomFragment() {
    }

    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        if (0 != optionsMenuResourceId) {
            inflater.inflate(optionsMenuResourceId, menu);
        }
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        optionsMenuResourceId = this.optionsMenuResourceId();
        setHasOptionsMenu(0 != optionsMenuResourceId);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        viewLayoutId = this.viewLayoutId();
        return inflater.inflate(viewLayoutId, null);
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        this.viewDidLoad();
    }
}
